/**
 * Copyright (c) 2008,中企动力华南研发中心
 * All rights reserved.
 */

package com.ce.pms.customer.dao.impl;

import java.util.List;

import org.hibernate.Hibernate;
import org.hibernate.Query;
import com.ce.pms.base.dao.impl.PmsBaseDaoImpl;
import com.ce.pms.customer.dao.IChooseSingleHouseDao;
import com.ce.pms.customer.model.ClientDO;
/**
 * 逻辑、功能相关描述:
 * @author 易贤建  编写日期：2008-5-22
 */
public class ChooseSingleHouseDaoImpl extends PmsBaseDaoImpl implements IChooseSingleHouseDao {
	/**
     * Function:通过楼栋ID查找房屋列表。
     * Create author:yixianjian
     * Create on:2008-5-22
	 */
	@Deprecated
	public List findMember(Long buildId,Long houseGrpId) {
		String queryStr = "from FlatDomain flatDO  where flatDO.building.keyword = ? and flatDO.houseGrp.keyword = ? order by flatDO.building.keyword,flatDO.floor desc,houseNumber asc";
		Query query = super.createQuery(queryStr, new Object[]{buildId,houseGrpId});

		return query.list();
	}

	/**
	* Function:通过房屋ID查询相关业主姓名
	* @param
	* @return
	* Create author:yixianjian
	* Create on:2008-6-17
	* Edit author:
	* Edit on:
	* Why:
	 */
	public List findClientNameByHouseId(Long houseId){
		StringBuffer queryStr = new StringBuffer("SELECT crh.client.participant.participantName FROM ClientRHouseDO crh ");
		queryStr.append("WHERE crh.house.id=?  AND crh.client.clientType='");
		queryStr.append(ClientDO.CT_OWNER) ;
		queryStr.append("'");
		Query query = super.createQuery(queryStr.toString(), new Object[]{houseId});
		return query.list();
	}
	/**
	 *
	* Function:通过楼栋ID查找房屋列表。
	* @param
	* @return
	* Create author:yixianjian
	* Create on:2008-6-6
	* Edit author:
	* Edit on:
	* Why:
	 */
	public List findMember(Long buildId){
		String queryStr = "from FlatDomain flatDO  where flatDO.houseGrp.building.keyword = ?  order by  flatDO.floor desc";
		Query query = super.createQuery(queryStr, new Object[]{buildId});

		return query.list();
	}
	/**
	* Function:通过管理区ID，查询楼栋ID，在UI中，显示下拉数据
	* 目前这里存在的问题：
	* Create author:yixianjian
	* Create on:2008-5-23
	 */
	public List getBuildingList(Long areaId) {
		String queryBuilding = "from BuildingDomain bdo";
		Query query = super.createQuery(queryBuilding, new Object[]{});
		List buildList = query.list();
		return buildList;
	}

}
